package com.fanghaoran.notes.dao.impl;

import com.fanghaoran.notes.dao.EvaluationDao;
import com.fanghaoran.notes.entity.Evaluation;
import com.fanghaoran.notes.entity.SensitiveBase;
import com.fanghaoran.notes.util.BaseDaoUtil;

import java.sql.SQLException;
import java.util.List;

/**
 * @Author: win11
 * @Date: 2023/04/24/11:49
 * @Description: 实现类
 */
public class EvaluationDaoImpl implements EvaluationDao {
    @Override
    public List<Evaluation> selectEvaluation(int iid) throws Exception {
        String sql="select * from evaluation where i_id=?;";
        return BaseDaoUtil.executeQuery(Evaluation.class,sql,iid);
    }

    @Override
    public Integer insertEvaluation(int uid,int iid, int score, String comment) throws SQLException {
        String sql = "insert into evaluation(u_id,i_id,score,comment) values(?,?,?,?);";
        return BaseDaoUtil.executeUpdate(sql,uid,iid,score,comment);
    }

    @Override
    public List<SensitiveBase> selectSensitiveBase() throws Exception {
        String sql = "select * from sensitive_base;";
        return BaseDaoUtil.executeQuery(SensitiveBase.class,sql);
    }
}
